
export function saveDataUrl(url, name) {
  let eleLink = document.createElement('a');
  eleLink.download = name;
  eleLink.style.display = 'none';
  eleLink.href = url;
  document.body.appendChild(eleLink);
  eleLink.click();
  // document.body.removeChild(eleLink);
}

export function saveBlobAs(blob, name) {
  console.log(blob)
  console.log(name)
  saveDataUrl(URL.createObjectURL(blob), name)
}

export function saveTextAs(text, filename) {
  saveDataUrl("data:text/plain;charset=utf-8," + encodeURIComponent(text), name)
}


export const socketUrl = `wss://guyaqi.com/s/`
export const webUrl = `https://guyaqi.com`

// export const socketUrl = `ws://127.0.0.1:30001/`
// export const webUrl = `http://127.0.0.1:30002`


export function goGithubOAuth() {
  const client_id = '9051298fc566ede36c3c'
  const scope = 'user'
  const target = `https://github.com/login/oauth/authorize?client_id=${client_id}&scope=${scope}`
  location.href = target
}
